<template>
  <div class="CustomeOrders">
    <div class="locationButton">
      <el-button type="primary"  @click="">帮助</el-button>
      <el-button type="primary"  @click="$router.go(-1)">返回</el-button>
    </div>
    <el-form :inline="true" class="demo-form-inline">
      <div class="locationItem">
        <el-form-item label="订单编号">
          <el-input class="input-item" v-model="order.id" disabled></el-input>
        </el-form-item>
        <el-form-item label="日　　期">
          <el-input class="input-item" v-model="order.orderTime" disabled></el-input>
        </el-form-item>
        <el-form-item label="送货地址">
          <el-input class="input-item" v-model="order.address" disabled></el-input>
        </el-form-item><br />
        <el-form-item label="总金额(元)">
          <el-input class="input-item" v-model="order.amount" disabled></el-input>
        </el-form-item>
        <el-form-item label="状　　态">
          <el-input class="input-item" v-model="order.state" disabled></el-input>
        </el-form-item>
      </div>
    </el-form>
    <el-table :data="tableData.records" :highlight-current-row="true" style="max-height: 75%;width: 100%;">
      <el-table-column prop="id" :align="'center'" label="编号" width="120" />
      <el-table-column prop="productName" label="商品" width="120" />
      <el-table-column prop="quantity" :align="'center'" label="数量" />
      <el-table-column prop="price" :align="'center'" label="单价(元)" />
      <el-table-column prop="amount" :align="'center'" label="金额" />
      </el-table-column>
    </el-table>
    <div class="pager">
      <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page.sync="current"
        :page-sizes="[5, 10, 15, 20]" :page-size="pageSize" layout="total, sizes, prev, pager, next, jumper"
        :total="tableData.total">
      </el-pagination>
    </div>
  </div>
</template>

<script>
  export default {
    name: 'CustomerContact',
    data() {
      return {
        modName: '订单明细',
        event: '',
        currentIndex: '',
        currentRow: '',
        order: {},
        relationship: {},
        tableData: [],
        current: 1,
        pageSize: 5,
        dialogFormVisible: false
      }
    }, methods: {
      getRouterData() {
        this.order = JSON.parse(sessionStorage.getItem('order'));
        this.order.state = this.order.state == 0 ? '已回款' : '未回款';
      }, handleSizeChange(val) {
        this.pageSize = val;
        this.getOrderDetails();
      }, handleCurrentChange(val) {
        this.current = val;
        this.getOrderDetails();
      }, cancel() {
        this.dialogFormVisible = false;
        this.relationship = {};
      }, getOrderDetails() {
        let _this = this;
        _this.$http.get('/customer/customerInfo/orders/orderDetails', {
          params: {
            pageIndex: _this.current,
            pageSize: _this.pageSize,
            orderId: _this.order.id
          }
        }).then(function (ret) {
          _this.tableData = ret.data;
        });
      }, sendeRequest(method, url, param) {  //实现更新请求的代码复用
        let _this = this;
        param = method == 'delete' ? { params: param } : param;
        this.$http[method](url, param).then(function (ret) {
          if (ret.data.code == 0) {
            _this.$notify({
              title: ret.data.msg,
              message: '😀',
              type: 'success'
            });
          } else {
            _this.$notify.error({
              title: ret.data.msg,
              message: '😭',
              type: 'error'
            });
          }
        });
      }
    }, created() {
      this.getRouterData(); //获取路由传递的参数
      this.getOrderDetails(); //获取订单明细数据
    }
  }
</script>

<style scoped>
  .CustomerContact {
    padding: 30px 30px;
    margin: 30px auto;
  }


  .locationButton {
   float: right;
  }

  .locationItem {
    margin-top: 50px;
  }

  .el-form-item {
    margin-top: 0px;
  }

  .input-item {
    width: 305.4px;
  }

  .pager {
    text-align: center;
    margin-top: 10px;
  }

  .el-input,
  .el-select {
    width: 260px;
  }
</style>